<template>
    <van-sticky>
        <van-nav-bar title="首页" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-search v-model="value" shape="round" background="#fff" placeholder="请输入搜索关键词" />
    </van-sticky>
    <div>
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
            <van-swipe-item v-for="(item, index) in arr" :key="index">
                <img :src="item.image_src" />
            </van-swipe-item>
        </van-swipe>
        <van-grid :column-num="4">
            <van-grid-item v-for="(item, index) in crr" :key="index" :icon="item.image_src"/>
        </van-grid>
    </div>
    <div v-for="(item, index) in brr" :key="index">
        <img :src="item.floor_title.image_src" alt="">
        <div v-for="(items, index) in item.product_list" :key="index">
            <img :src="items.image_src" alt="">
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import axios from 'axios';
const onClickLeft = () => history.back();
let arr = ref([])
let crr = ref([])
let brr = ref([])
axios.get('https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata').then(res => {
    arr.value = res.data.message
})
axios.get('https://api-hmugo-web.itheima.net/api/public/v1/home/catitems').then(res => {
    crr.value = res.data.message
})
axios.get('https://api-hmugo-web.itheima.net/api/public/v1/home/floordata').then(res => {
    brr.value = res.data.message
})
</script>
<style>
.my-swipe .van-swipe-item {
    width: 200px;
    height: 200px;
}

img {
    width: 400px;
    height: 200px;
}

</style>